bitkeeper revision 1.1108.1.44 (411354999nduqdyeTZj322J-xHX8zw)
authorsos22@donkeykong.cl.cam.ac.uk <sos22@donkeykong.cl.cam.ac.uk>
Fri, 6 Aug 2004 09:51:21 +0000 (09:51 +0000)
committersos22@donkeykong.cl.cam.ac.uk <sos22@donkeykong.cl.cam.ac.uk>
Fri, 6 Aug 2004 09:51:21 +0000 (09:51 +0000)
Add support for detaching and resuming.  It isn't obvious that
these are useful things to do in what is nominally a post-mortem
debugger, but do it anyway.

xen/arch/x86/xdb.c

index 1b5bd0feb0d3ddba75281b044d196345ee955506..b7bf77057a1cf45f7af94fd6c5c068e6bb16105c 100644 (file)
@@ -14,6 +14,7 @@
 struct xendbg_context {
        int serhnd;
        u8 reply_csum;
+       int currently_attached:1;
 };
 
 static void
@@ -250,9 +251,20 @@ process_command(char *received_packet, struct pt_regs *regs,
                        break;
                case 'D':
                        resume = 1;
+                       ctx->currently_attached = 0;
                        retry = xendbg_send_reply("", ctx);
                        break;
                case 'c': /* Resume at current address */
+                       ctx->currently_attached = 1;
+                       resume = 1;
+                       retry = 0;
+                       break;
+               case 'Z': /* We need to claim to support these or gdb
+                            won't let you continue the process. */
+               case 'z':
+                       retry = xendbg_send_reply("OK", ctx);
+                       break;
+
                case 's': /* Single step */
                case '?':
                        retry = xendbg_send_reply("S01", ctx);
@@ -306,6 +318,13 @@ __trap_to_xendbg(struct pt_regs *regs)
           interrupts while we're here. */
        local_irq_save(flags);
 
+       /* If gdb is already attached, tell it we've stopped again. */
+       if (xdb_ctx.currently_attached) {
+               do {
+                       r = xendbg_send_reply("S01", &xdb_ctx);
+               } while (r != 0);
+       }
+
        while (resume == 0) {
                r = receive_command(recv_buf, &xdb_ctx);
                if (r < 0) {